<template>
    <div class="easyd-weixin-Box">

        <div class="app_page">
            <div class="communication_list app_box_content_list app_list_box" v-for="item in followUpData" @click="userDetail(item)">
                <!--<img src="../../../../static/images/fuwukaxiangqing3.jpg" />-->
                <div class="txt_img">
                    {{item.c_name[0]}}
                </div>
                <div class="communication_info">
                    <div class="app_box_flex" v-if="$route.query.source != 'jinrichengjiao'">
                        <div class="app_box_content_left">
                            {{item.c_campus_name}}
                        </div>
                        <div class="app_box_content_right" style="color: #FE4117;" v-if="item.c_follow_status == 0">
                            待跟进
                        </div>
                        <div class="app_box_content_right" style="color: #FE4117;" v-if="item.c_follow_status == 1">
                            跟进中
                        </div>
                    </div>
                    <div class="app_box_flex" v-else>
                        <div class="app_box_content_left">
                            {{item.c_campus_name}}
                        </div>
                        <div class="app_box_content_right" style="color: #FE4117;" v-if="item.c_is_buy == 1">
                            已成交
                        </div>
                    </div>

                    <div class="app_box_flex">
                        <div class="app_box_content_left">
                            <span class="T2">{{item.c_name}}</span>&nbsp;<span class="C4 T3">{{item.c_phone}}</span>
                        </div>
                        <div class="app_box_content_right C4" v-if="item.c_evaluation == 0">
                            一类客户
                        </div>
                        <div class="app_box_content_right C4" v-if="item.c_evaluation == 1">
                            二类客户
                        </div>
                        <div class="app_box_content_right C4" v-if="item.c_evaluation == 2">
                            三类客户
                        </div>
                        <div class="app_box_content_right C4" v-if="item.c_evaluation == 3">
                            四类客户
                        </div>
                        <div class="app_box_content_right C4" v-if="item.c_evaluation == 4">
                            五类客户
                        </div>
                    </div>
                </div>
                <div class="communication_time C2 T3">
                    <span class="app_float_left" v-if="!item.provinceName"><span class="C1">地址：暂无</span></span>
                    <span class="app_float_left C4" v-else=""><span class="C1">地址：</span>{{item.provinceName ?item.provinceName:''}}{{item.cityName?item.cityName:''}}{{item.areaName?item.areaName:''}}{{item.c_address== null?'':item.c_address}}</span>
                    <!--<span class="app_float_right">{{$common.getTimes(item.c_create_time)}}</span>-->
                </div>
                <div class="communication_time C2 T3" v-if="$route.query.source=='kehugenjin'">
                    <!--<span class="app_float_left C4"><span class="C1">最近跟进：</span>{{followTypeData[item.followInfo.cfr_way]}}（{{item.followInfo.u_nickname}}）</span>
                    <span class="app_float_right C4">{{$common.getTimes(item.followInfo.cfr_create_time)}}</span>-->
                </div>
                <div class="communication_time C2 T3" v-else-if="$route.query.source=='jinrichengjiao' && item.followInfo.cfr_create_time">
                    <span class="app_float_left C4"><span class="C1">最近跟进：</span>{{followTypeData[item.followInfo.cfr_way]}}（{{item.followInfo.u_nickname}}）</span>
                    <span class="app_float_right C4">{{$common.getTimes(item.followInfo.cfr_create_time,"shifen")}}</span>
                </div>
                <div class="communication_time C2 T3" v-else-if="$route.query.source=='jinrigenjin' && item.cfr_create_time">
                    <span class="app_float_left C4"><span class="C1">最近跟进：</span>{{followTypeData[item.cfr_way]}}（{{item.u_nickname}}）</span>
                    <span class="app_float_right C4">{{$common.getTimes(item.cfr_create_time,"shifen")}}</span>
                </div>
                <div class="communication_time C2 T3" v-else-if="item.followInfo.cfr_create_time && $route.query.source=='jinrixinzeng'">
                    <span class="app_float_left C4"><span class="C1">最近跟进：</span>{{followTypeData[item.followInfo.cfr_way]}}（{{item.followInfo.u_nickname}}）</span>
                    <span class="app_float_right C4">{{$common.getTimes(item.followInfo.cfr_create_time,"shifen")}}</span>
                </div>
                
            </div>
        </div>

    </div>
</template>

<script>
    import {mapState, mapMutations} from "vuex";

    export default {

        data() {
            return {
				followTypeData : ['电话跟进','上门跟进','QQ跟进','微信跟进','短信跟进'],
			};
        },
        computed: {
            ...mapState({
                followUpData: state => state.ClientFollowModule.followUpData,
                tempSell: state => state.HomeModule.tempSell,
                tempSellAll: state => state.HomeModule.tempSellAll,
            }),
        },
        mounted() {

            //修改标题
            switch (this.$route.query.source) {
                case 'kehugenjin':
                    document.title = '客户跟进';
                    break;
                case 'jinrixinzeng':
                    document.title = '今日新增';
                    break;
                case 'jinrigenjin':
                    document.title = '今日跟进';
                    break;
                case 'jinrichengjiao':
                    document.title = '今日成交';
                    break;
                default:
                    break;
            }

            this.initData()

        },
        methods: {

            //  ...mapMutations(["ShopIndexModule/updateIsShopGuide"]),

            initData() {

                var uids = this.$userData.getUID();
                if (this.tempSell) {
                    uids = this.tempSell;
                }
                
                //是否是超管
                var isRoot = "/is_manager/0";
//              if(this.$userData.getUID()==1){
//              	isRoot = "/is_manager/1";
//              }
//              
                if (this.tempSellAll.u_master_osid != undefined && this.tempSellAll.u_master_osid != null && this.tempSellAll.u_master_osid != '') {
                	
                    if(this.tempSellAll.is_group_leader == '1'){
	                	isRoot = ''
	                	+ "/is_manager/0" 
	                    + "/u_id/" + this.tempSellAll.u_id
	                    + "/os_id/" + this.tempSellAll.u_master_osid
	                    + "/u_type/" + this.tempSellAll.u_type 
	                    + "/u_leader/" + this.tempSellAll.u_leader;
                    }else{
	                	isRoot = ''
	                    + "/u_id/" + this.tempSellAll.u_id
	                    + "/os_id/" + this.tempSellAll.u_master_osid
	                    + "/is_manager/" + this.tempSellAll.u_is_manager 
	                    + "/u_type/" + this.tempSellAll.u_type 
	                    + "/u_leader/" + this.tempSellAll.u_leader;
                    }
            	}else{
            		isRoot = ''
                    + "/u_id/" + this.$userData.getUID()
                    + "/os_id/" + this.$userData.getOsid()
                    + "/is_manager/" + this.$userData.getIsManager() 
                    + "/u_type/" + this.$userData.getOsType() 
                    + "/u_leader/" + this.$userData.getLeader();
            	}
                
                var aipUrl = '';
                switch (this.$route.query.source) {
                    case 'kehugenjin':
                        aipUrl = this.$API.apiFollowUpCustomers;
                        break;
                    case 'jinrixinzeng':
                        aipUrl = this.$API.apiNewCustomersToday;
                        break;
                    case 'jinrigenjin':
                        aipUrl = this.$API.apiFollowUpWithCustomersToday;
                        break;
                    case 'jinrichengjiao':
                        aipUrl = this.$API.apiCustomersWhoBuyProductsToday;
                        break;
                    default:
                        break;
                }

                this.$easyUtil.startLoading(this)
                this.$http.getHttp(
                    aipUrl + isRoot,
                    rs => {
                        switch (this.$route.query.source) {
                            case 'kehugenjin':
                                this.$store.commit("ClientFollowModule/updateFollowData", rs.waitForFlowingCustomers);
                                break;
                            case 'jinrixinzeng':
                                this.$store.commit("ClientFollowModule/updateFollowData", rs.newCustomerToday);

                                break;
                            case 'jinrigenjin':
                                var customerArr = [];
                                for (var i = 0; i < rs.followUpToday.length; i++) {
                                    customerArr.push(rs.followUpToday[i].customerInfo[0])
                                }
                                this.$store.commit("ClientFollowModule/updateFollowData", customerArr);
                                break;
                            case 'jinrichengjiao':
                                var customerOrderedArr = [];
                                for (var m = 0; m < rs.customerTodayOrders.length; m++) {
                                	var tempItem = rs.customerTodayOrders[m].customerInfo[0];
                                	tempItem.followInfo = rs.customerTodayOrders[m].followInfo;
                                    customerOrderedArr.push(tempItem)
                                }
                                this.$store.commit("ClientFollowModule/updateFollowData", customerOrderedArr);
                                break;
                            default:
                                break;
                        }
                        
                        this.$easyUtil.endLoading(this)

                        this.getNodeData(0, 0);
                    }
                );
            },

            //用户详情
            userDetail(item) {
                this.$router.push({
                    path:'/userDetail',
                    query:{
                        customerId : item.c_id,
                        isShowStopCustom : false
                    }
                })
            },
        }
    };
</script>

<style lang="stylus" scoped>
    @import '~PUBLIC_CSS';
    .top_menu {
    }

    .top_menu .app_box_content_right {
        text-align: center;
        border-right: 2px solid #f6f6f6;
        font-size: small;
        padding: 0;
    }

    .top_menu .app_box_content_right:last-child {
        border-right: 0;
    }

    .communication_list {
        overflow: hidden;
    }

    .communication_list .communication_info {
        float: initial;
    }

    .communication_list .communication_time {
        overflow: hidden;
        width: 100%;
    }

    .communication_list .communication_time .app_float_left {
	    overflow: hidden;
	    text-overflow: ellipsis;
	    white-space: nowrap;
	    width: 60%;
    }

    .communication_list .communication_time .app_float_right {
        /*border: 1px solid #fbd415;
        padding: 0 10px;
        line-height: initial;
        border-radius: 4px;
        margin-top: 5px;*/
    }

    .communication_list .txt_img {
        display: block;
        height: 40px;
        width: 40px;
        margin: 10px;
        margin-left: 0;
        text-align: center;
        line-height: 40px;
        background: #000;
        color: gold;
        float: left;
        border-radius: 100px;
        object-fit: cover;
    }

    .communication_list img {
        display: block;
        height: 50px;
        width: 70px;
        padding: 5px 10px 5px 0;
        float: left;
        object-fit: cover;
    }
</style>